package com.mjw.zstu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mjw.zstu.entity.Orderlist;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
public interface OrderMapper extends BaseMapper<Orderlist> {
    @Select("select exhibition.address as ex_address, shipping_address.city,shipping_address.address,`product`.name,product.price,product.img_url,`orderlist`.*,`exhibition`.name as ex_name ,company.company_name,exhibition.start_time,exhibition.end_time  from `orderlist`,product,exhibition,company,shipping_address where `orderlist`.product_id=`product`.id and `product`.exhibition_id=exhibition.id and product.company_id=#{company_id} and exhibition.company_id=company.company_id and orderlist.status=#{status} and shipping_address.id=orderlist.address_id order by orderlist.create_time DESC")
    public List<Map> getCompanyOrder(int company_id,int status);
    @Select("select exhibition.address as ex_address, shipping_address.city,shipping_address.address,`product`.name,product.price,product.img_url,`orderlist`.*,`exhibition`.name as ex_name ,company.company_name,exhibition.start_time,exhibition.end_time  from `orderlist`,product,exhibition,company,shipping_address where `orderlist`.product_id=`product`.id and `product`.exhibition_id=exhibition.id and exhibition.company_id=company.company_id and orderlist.status=#{status} and shipping_address.id=orderlist.address_id order by orderlist.create_time DESC")
    public List<Map> all_list(int status);
    @Select("select product.name,product.price,product.img_url,`orderlist`.*,shipping_address.*  from `orderlist`,product,shipping_address where `orderlist`.product_id=product.id and orderlist.address_id=shipping_address.id  and `orderlist`.company_id=#{id} and `orderlist`.status=#{status}")
    public List<Map> getbuyerCompanyOrder(int id,int status);
    @Select("select shipping_address.city,shipping_address.address, product.name,product.img_url,`orderlist`.* ,shipping_address.* from `orderlist`,shipping_address,product where `orderlist`.product_id=product.id and orderlist.address_id=shipping_address.id and  `orderlist`.user_id=#{id} and `orderlist`.status=#{status} and shipping_address.id=orderlist.address_id order by orderlist.create_time DESC")
    public List<Map> getbuyerUserOrder(int id,int status);
    @Select("select product.*,`orderlist`.*  from `orderlist`,product,shipping_address where `orderlist`.product_id=product.id and orderlist.address_id=shipping_address.id and product.company_id=#{id}")
    public List<Map> getCompanysalerOrder(int id);
    @Select("select shipping_address.city,shipping_address.address, orderlist.*, product.name ,product.price as pro_price,product.img_url,exhibition.name as exhibition_name,company.company_name as ex_company from product,orderlist,`exhibition`,company,shipping_address where `exhibition`.company_id=company.company_id  and product.id=orderlist.product_id and `exhibition`.id=product.exhibition_id and orderlist.id=#{id} and shipping_address.id=orderlist.address_id")
    public Map getdetail(int id);
    @Select("select company.company_name from product,orderlist,company where orderlist.product_id=product.id and product.company_id=company.company_id and orderlist.id=#{id}")
    public Map getseller(int id);
    @Select("select exhibition.name as ex_name,exhibition.start_time,exhibition.end_time, shipping_address.city,shipping_address.address, company.company_name as zb_name,orderlist.*,product.img_url,product.name,product.price as pro_price from shipping_address,orderlist,product,exhibition,company where orderlist.product_id=product.id and product.company_id=#{company_id} and orderlist.status=#{status} and product.exhibition_id=exhibition.id and exhibition.company_id=company.company_id and orderlist.address_id=shipping_address.id")
    public List<Map> getCompanySalerOrder(int company_id,int status);
    @Select("select orderlist.*")
    public List<Map> getListbyOrderid(String order_id);
    @Select("select exhibition.address as ex_address, shipping_address.city,shipping_address.address,`product`.name,product.price,product.img_url,`orderlist`.*,`exhibition`.name as ex_name ,company.company_name,exhibition.start_time,exhibition.end_time  from `orderlist`,product,exhibition,company,shipping_address where `orderlist`.product_id=`product`.id and `product`.exhibition_id=exhibition.id and exhibition.company_id=company.company_id and orderlist.company_name=#{company_name} and shipping_address.id=orderlist.address_id order by orderlist.create_time DESC")
    public List<Map> getListbycompanyname(String company_name);


}
